package com.example.blog_system_ssm.common;

import com.example.blog_system_ssm.model.UserInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class SessionUtil {
    //查询当前用户的session信息
    public static UserInfo getLoginUser(HttpServletRequest request){
        HttpSession session= request.getSession(false);
        if(session!=null&&session.getAttribute(Constant.SESSION_USERINFO_KEY)!=null){
            return (UserInfo) session.getAttribute(Constant.SESSION_USERINFO_KEY);
        }
        return null;
    }
}
